package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.XcDept;
import com.qfedu.stussm.service.intf.XcDeptService;
import com.qfedu.stussm.vo.DeptR;
import com.qfedu.stussm.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class XcDeptController {
    @Autowired
    private XcDeptService xcdeptService;

    @RequestMapping("api/stussm/xcinsert.do")
    public DeptR insert(XcDept xcDept){
        System.out.println(xcDept);
        return xcdeptService.insert(xcDept);
    }



    @GetMapping("api/stussm/xcselect.do")
    public PageBeanVo select(String name,int page,int limit){
        PageBeanVo select = xcdeptService.select(name,page, limit);
        //   System.out.println("controller:"+name);
        return select;
    }

    @GetMapping("api/stussm/xcdel.do")
    public DeptR del(Integer id){
        System.out.println(id);
        return xcdeptService.del(id);
    }

    @PostMapping("api/stussm/xcupdate.do")
    public DeptR update(XcDept xcDept){
        DeptR update = xcdeptService.update(xcDept);
        System.out.println(xcDept);
        return update;
    }
    @PostMapping("api/stussm/xcdelmany.do")
    public DeptR dele(Integer[] id) {
        System.out.println("ids:" + id);
        if (id == null) {
            return DeptR.fail();
        } else {
            for (Integer i : id) {
                System.out.println(i);
            }
            return xcdeptService.dele(id);
        }
    }
}
